<!--
 * @Descripttion: 查询日期格式化规则
 * @version: 
 * @Author: 淏
 * @Date: 2023-11-23 21:24:05
 * @LastEditors: 淏
 * @LastEditTime: 2023-11-25 21:35:11
-->
<template>
  <el-select
    ref="selectDate"
    v-model="value"
    size="mini"
    placeholder="请选择日期规则"
    :popper-append-to-body="false"
    style="width: 250px"
  >
    <el-option
      v-for="(item, index) in options"
      :key="index"
      :label="item.code"
      :value="item.id"
    ></el-option>
  </el-select>
</template>

<script>
  import { query_dateFormatRule } from '@/api/index.js'
  export default {
    // 组件名称
    name: 'selectDateRule',
    // 组件参数 接收来自父组件的数据
    props: {},
    // 局部注册的组件
    components: {},
    // 组件状态值
    data() {
      return {
        options: [],
        value: '',
        chooseData: '',
      }
    },
    // 计算属性
    computed: {},
    // 侦听器
    watch: {
      value(value) {
        this.findData(value)
      },
    },
    // 组件方法
    methods: {
      getData() {
        query_dateFormatRule().then((res) => {
          this.options = res.data
        })
      },
      findData(row) {
        this.chooseData = this.options.find((item) => {
          return item.id == row
        })
        this.$emit('getDataRule', this.chooseData)
      },
    },
    created() {},
    mounted() {
      this.getData()
    },
  }
</script>

<style scoped></style>
